package info.galudisu;

import io.netty.channel.EventLoopGroup;
import io.netty.util.internal.resources.platform.DefaultLoopNativeDetector;
import io.netty.util.internal.resources.thread.LocalThreadFactory;

import java.util.concurrent.atomic.AtomicInteger;

public interface Launch {

  Integer CPU_CORE = Runtime.getRuntime().availableProcessors();

  void createEventLoopGroup();

  void startServer();

  void closeChannel();

  void shutdownGraceFully();

  default EventLoopGroup createEventLoopGroup(boolean daemon, int threads, String prefix) {
    final AtomicInteger atomicInteger = new AtomicInteger();
    return DefaultLoopNativeDetector.INSTANCE.newEventLoopGroup(
        threads, new LocalThreadFactory(daemon, atomicInteger, prefix));
  }
}
